﻿@model IEnumerable<DAL.UserCrad>

@{
    Layout = null;
}

<link href="~/css/bootstrap.css" rel="stylesheet">
<script src="~/js/jquery-3.3.1.js"></script>
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>GS</title>
</head>
<body>
    <input type="hidden"  value="@Url.Content("~/AdminPage/")" id="Path"/>
    <table class="table" border="1">
        <tr>
            <th>
                卡号
            </th>
            <th>
                姓名
            </th>
            <th>
                身份证
            </th>
            <th>
                手机号
            </th>
            <th>
                余额
            </th>

            <th>
                状态
            </th>
            <th></th>
        </tr>

        @foreach (var item in Model)
        {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.IdentityCrad)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Phone)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Money)
        </td>
        <td>
            @((item.CradStatic == 0 ? "正在使用" : "正在挂失"))
        </td>
        <td>
            @if (item.CradStatic == 0)
            {
                <a href="javascript:void(0);" onclick="gg(this,@item.ID, 1)">挂失</a>
            }
            else
            {
                <a href="javascript:void(0);" onclick="gg(this,@item.ID, 0)">取消挂失</a>
            }
            <br />
            <a href="javascript:void(0);" onclick="quentrunning(@item.ID)">查看流水</a>
        </td>

    </tr>
        }

    </table>
</body>
</html>
<script>
    var path = $("#Path").val();

    $(function () {

    });

    function gg(t, id, static) {
        $.post(path+"\GSs", { card: id, cardstatic: static }, function (data) {
          
            if (data.f) {
                if (static == 0) {
               
                    $(t).parent().prev().text("正在使用");
                    $(t).text("挂失");
                } else {
                     $(t).parent().prev().text("正在挂失");
                    $(t).text("取消挂失");
                }
                
            }
        },"json")
    }

    function quentrunning(id) {
        $.post(path + "\QuenyRunning", { card: id }, function (data) {
            if (data.f) {
                var mes = "";
                $(data.data).each(function (index, item) {
                    mes += "金额" + item.Money + "备注" + item.Remark+"\n";
                })
                alert(mes);
            } else {
                alert(data.mes);
            }

        },"json")
    }


</script>
